import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/mes-product/processprice/page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};
// 作废工艺
export const cancellation = (row) => {
  return request({
    url: '/api/mes-product/processprice/cancellation',
    method: 'post',
    data: row
  });
};

// 删除工艺
export const remove = (row) => {
  return request({
    url: '/api/mes-product/processprice/remove',
    method: 'post',
    data: row
  });
};
// 删除工序单价配置
export const removeRoute = (row) => {
  return request({
    url: '/api/mes-product/processprice/remove-route',
    method: 'post',
    data: row
  });
};
// 删除物料单价配置
export const removeMaterial = (row) => {
  return request({
    url: '/api/mes-product/processprice/remove-material',
    method: 'post',
    data: row
  });
};

// 审核
export const priceAudit = (row) => {
  return request({
    url: '/api/mes-product/processprice/audit',
    method: 'POST',
    data: row
  });
};

export const getDetail = (id) => {
  return request({
    url: '/api/mes-product/processprice/detail',
    method: 'get',
    params: {
      id
    }
  });
};

// 新增或编辑工艺单价配置
export const add = (row) => {
  return request({
    url: '/api/mes-product/processprice/submit',
    method: 'post',
    data: row
  });
};

// 计算工序单价
export const calculateRoutePrice = (row) => {
  return request({
    url: '/api/mes-product/processprice/calculate-process-route-price',
    method: 'post',
    data: row
  });
};

// 计算工艺单价
export const calculatePrice = (row) => {
  return request({
    url: '/api/mes-product/processprice/calculate-process-price',
    method: 'post',
    data: row
  });
};

// 工站单价分页
export const getPriceList = (current, size, params) => {
  return request({
    url: '/api/mes-product/routeprice/page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

// 根据产品编码，查询产品工艺
export const processProductRouteByPartno = (partNo) => {
  return request({
    url: '/api/mes-product/process/product-route/get-by-part-no',
    method: 'get',
    params: {
      partNo
    }
  });
};

export const getSectionList = (current, size, params) => {
  return request({
    url: '/api/mes-product/product-section-price/page-query',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const cancellationSection = (ids) => {
  return request({
    url: '/api/mes-product/product-section-price/cancel',
    method: 'get',
    params: {
      ids
    }
  });
};

export const sectionPriceAudit = (ids) => {
  return request({
    url: '/api/mes-product/product-section-price/approved',
    method: 'get',
    params: {
      ids
    }
  });
};

export const sectionEdit = (data) => {
  return request({
    url: '/api/mes-product/product-section-price/submit',
    method: 'post',
    data
  });
};

export const sectionDetail = (id) => {
  return request({
    url: '/api/mes-product/product-section-price/detail',
    method: 'get',
    params: {
      id
    }
  });
};

export const getSection = (partNo) => {
  return request({
    url: '/api/mes-product/part-master/section/page',
    method: 'get',
    params: {
      partNo,
      current: 1,
      size: 15
    }
  });
};
